/*
 * @Author: shawnxiao
 * @Date: 2021-07-06 14:16:36
 * @LastEditTime: 2021-11-19 10:00:05
 * @FilePath: /gatt-react/src/index/components/ModelCustom/index.tsx
 */
import React from 'react'
import { Modal } from 'antd'
import {CloseOutlined } from '@ant-design/icons'
import './index.less'

interface ArgsProps {
  title?: string;
  vNode?: any;
  okText?: string;
  className?: string;
  callback?: Function;
}

function ModelCustom(args:ArgsProps) {
  Modal.info({
    width: '30%',
    mask: true,
    maskClosable: true,
    // eslint-disable-next-line react/display-name
    modalRender: () => (
      <div className={`modal-custom-box ${args?.className}`}>
        <h2 className="modal-custom-box-title">
          {args?.title} <CloseOutlined onClick={() => Modal.destroyAll()} />
        </h2>
        <div className="modal-custom-box-content">
          {
            args?.vNode
          }
        </div>
      </div>
    ),
    onOk(close:() => void) {
      args?.callback && args.callback()
      close && close()
    }
  })
}

export default ModelCustom
